home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / WVPanelDbQueryWhere.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  6.7 KB  |  159 lines

  1. package asp.wizard;
  2.  
  3. import asp.util.ResourceUtil;
  4. import asp.wizard.util.UiUtil;
  5. import com.sun.java.swing.ComboBoxEditor;
  6. import com.sun.java.swing.DefaultCellEditor;
  7. import com.sun.java.swing.JButton;
  8. import com.sun.java.swing.JComboBox;
  9. import com.sun.java.swing.JPanel;
  10. import com.sun.java.swing.JScrollPane;
  11. import com.sun.java.swing.JTable;
  12. import com.sun.java.swing.table.DefaultTableModel;
  13. import com.sun.java.swing.table.TableColumnModel;
  14. import java.awt.Color;
  15. import java.awt.Component;
  16. import java.awt.Container;
  17. import java.awt.GridBagConstraints;
  18. import java.awt.GridBagLayout;
  19. import java.util.EventObject;
  20. import java.util.Vector;
  21.  
  22. public class WVPanelDbQueryWhere extends WVPanelBase {
  23.    private static final String ID_BTN_ADD = "button.add";
  24.    private static final String ID_BTN_DELETE = "button.delete";
  25.    private static final String ID_LBL_HDRFIELD = "label.headerfield";
  26.    private static final String ID_LBL_HDRFILTER = "label.headerfilter";
  27.    private static final String ID_LBL_HDRVALUE = "label.headervalue";
  28.    private static final int INIT_ROWS = 0;
  29.    JButton _btnAdd;
  30.    JButton _btnDelete;
  31.    JComboBox _cboCritPrefix;
  32.    JComboBox _cboLhs;
  33.    JComboBox _cboOperator;
  34.    JComboBox _cboRhs;
  35.    JComboBox _cboCritSuffix;
  36.    JTable _tblCriteria;
  37.    DefaultTableModel _tbmCriteria;
  38.    JScrollPane _scpCriteria;
  39.  
  40.    protected void initModels() {
  41.       super.initModels();
  42.       ResourceUtil ru = ((WVPanelBase)this).getResourceUtil();
  43.       Vector tableColumns = new Vector();
  44.       tableColumns.addElement(" ");
  45.       tableColumns.addElement(ru.getString("label.headerfield"));
  46.       tableColumns.addElement(ru.getString("label.headerfilter"));
  47.       tableColumns.addElement(ru.getString("label.headervalue"));
  48.       tableColumns.addElement(" ");
  49.       Vector tableData = new Vector(0);
  50.       Vector tableRow = null;
  51.  
  52.       for(int i = 0; i < 0; ++i) {
  53.          tableRow = new Vector();
  54.          tableRow.setSize(5);
  55.          tableData.addElement(tableRow);
  56.       }
  57.  
  58.       this._tbmCriteria = new DefaultTableModel();
  59.       this._tbmCriteria.setDataVector(tableData, tableColumns);
  60.    }
  61.  
  62.    protected void initComponents() {
  63.       super.initComponents();
  64.       ResourceUtil ru = ((WVPanelBase)this).getResourceUtil();
  65.       JPanel contentPanel = ((WVPanelBase)this).getContentPanel();
  66.       Color bgcolor = ((Component)contentPanel).getBackground();
  67.       this._btnAdd = new JButton(ru.getString("button.add").trim());
  68.       this._btnAdd.setMnemonic(ru.getMnemonic("button.add"));
  69.       this._btnDelete = new JButton(ru.getString("button.delete"));
  70.       this._btnDelete.setMnemonic(ru.getMnemonic("button.delete"));
  71.       this._cboCritPrefix = new JComboBox();
  72.       this._cboCritPrefix.setEditable(false);
  73.       this._cboLhs = new JComboBox();
  74.       this._cboLhs.setEditable(false);
  75.       this._cboOperator = new JComboBox();
  76.       this._cboOperator.setEditable(false);
  77.       this._cboRhs = new JComboBox();
  78.       this._cboRhs.setEditable(true);
  79.       this._cboRhs.addItemListener(new 1());
  80.       this._cboCritSuffix = new JComboBox();
  81.       this._cboCritSuffix.setEditable(false);
  82.       this._tblCriteria = new JTable();
  83.       this._tblCriteria.setModel(this._tbmCriteria);
  84.       TableColumnModel tcm = this._tblCriteria.getColumnModel();
  85.       this._scpCriteria = JTable.createScrollPaneForTable(this._tblCriteria);
  86.       DefaultCellEditor cde = new DefaultCellEditor(this._cboCritPrefix);
  87.       cde.setClickCountToStart(2);
  88.       tcm.getColumn(0).setCellEditor(cde);
  89.       cde = new DefaultCellEditor(this._cboLhs);
  90.       cde.setClickCountToStart(2);
  91.       tcm.getColumn(1).setCellEditor(cde);
  92.       cde = new DefaultCellEditor(this._cboOperator);
  93.       cde.setClickCountToStart(2);
  94.       tcm.getColumn(2).setCellEditor(cde);
  95.       cde = new CustomComboBoxCellEditor(this, this._cboRhs);
  96.       cde.setClickCountToStart(2);
  97.       cde.addCellEditorListener(new 2());
  98.       tcm.getColumn(3).setCellEditor(cde);
  99.       cde = new DefaultCellEditor(this._cboCritSuffix);
  100.       cde.setClickCountToStart(2);
  101.       tcm.getColumn(4).setCellEditor(cde);
  102.       int nWidth = 494;
  103.       tcm.getColumn(0).setMaxWidth(nWidth / 9);
  104.       tcm.getColumn(0).setWidth(nWidth / 9);
  105.       tcm.getColumn(1).setMaxWidth(nWidth / 3);
  106.       tcm.getColumn(1).setWidth(nWidth / 3);
  107.       tcm.getColumn(2).setMaxWidth(nWidth / 9);
  108.       tcm.getColumn(2).setWidth(nWidth / 9);
  109.       tcm.getColumn(3).setMaxWidth(nWidth / 3);
  110.       tcm.getColumn(3).setWidth(nWidth / 3);
  111.       tcm.getColumn(4).setMaxWidth(nWidth / 9);
  112.       tcm.getColumn(4).setWidth(nWidth / 9);
  113.       this._tblCriteria.setAutoResizeMode(0);
  114.       this._tblCriteria.getTableHeader().setReorderingAllowed(false);
  115.       this._tblCriteria.getTableHeader().setResizingAllowed(false);
  116.    }
  117.  
  118.    protected void initLayout() {
  119.       super.initLayout();
  120.       JPanel contentPanel = ((WVPanelBase)this).getContentPanel();
  121.       GridBagLayout gbl = new GridBagLayout();
  122.       GridBagConstraints gbc = new GridBagConstraints();
  123.       ((Container)contentPanel).setLayout(gbl);
  124.       gbc.ipady = 5;
  125.       UiUtil.addComponent(contentPanel, super._txpIntro, gbl, gbc, 0, 0, 3, 1, (double)1.0F, (double)0.0F, 10, 2, 0, 0, 10, 0);
  126.       gbc.ipady = 0;
  127.       UiUtil.addComponent(contentPanel, this._scpCriteria, gbl, gbc, 0, 1, 3, 1, (double)1.0F, (double)1.0F, 10, 1, 5, 5, 0, 5);
  128.       TableColumnModel tcm = this._tblCriteria.getColumnModel();
  129.       UiUtil.addComponent(contentPanel, new JPanel(), gbl, gbc, 0, 2, 1, 1, (double)1.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
  130.       UiUtil.addComponent(contentPanel, this._btnAdd, gbl, gbc, 1, 2, 1, 1, (double)0.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
  131.       UiUtil.addComponent(contentPanel, this._btnDelete, gbl, gbc, 2, 2, 1, 1, (double)0.0F, (double)0.0F, 13, 0, 10, 0, 0, 0);
  132.    }
  133.  
  134.    public void commitValue(EventObject evt) {
  135.       if (evt.getSource() instanceof DefaultCellEditor) {
  136.          DefaultCellEditor dce = (DefaultCellEditor)evt.getSource();
  137.          if (dce.getComponent() instanceof JComboBox) {
  138.             JComboBox comboBox = (JComboBox)dce.getComponent();
  139.             if (comboBox.isEditable()) {
  140.                ComboBoxEditor cbe = comboBox.getEditor();
  141.                if (cbe != null) {
  142.                   Object item = cbe.getItem();
  143.                   int editingRow = this._tblCriteria.getEditingRow();
  144.                   int editingColumn = this._tblCriteria.getEditingColumn();
  145.                   if (editingRow >= 0 && editingColumn >= 0) {
  146.                      this._tblCriteria.setValueAt(item, editingRow, editingColumn);
  147.                   }
  148.                }
  149.             }
  150.          }
  151.       }
  152.  
  153.    }
  154.  
  155.    public void commitValues(EventObject evt) {
  156.       System.out.println("handleComboBoxFocusLost");
  157.    }
  158. }
  159.